﻿//Author:Michal Sporna
//License: https://operationsneakpeek.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace World
{
    /// <summary>
    /// represents configuration of the world
    /// </summary>
    public class WorldConfig
    {
        #region properties
        public string GameTitle;
        public List<Levels.MapInfo> Maps;//paths to the map configuration files
        public List<Levels.npcPlacement> NpcPlacement;
        public List<Levels.ObstaclePlacement> ObstaclePlacement;
        public List<Levels.ItemPlacement> ItemPlacement;
        public List<Levels.BombPlacement> BombPlacement;
        public List<Levels.TexturePlacement> TexturePlacement;

        public int PointsNeededFor1Star;
        public int PointsNeededFor2Stars;
        public int PointsNeededFor3Stars;

        public int BreathTakeawayValue;//how much breath is taken every x seconds
        public int BreathTakeawayTime; //in what time interval avatar's breath is taken
        //when moving an avatar, the move pattern consits of checkpoints:
        public int CheckpointWidth;
        public int CheckpointHeight;

        public int MapSelectorFrameWidth;
        public int MapSelectorFrameHeight;
        public int MapSelectorTitleFrameHeight;
        public int MapSelectorStatisticsFrameHeight;

        //bomb defusing, cancel button width and height
        public int BombDefusingCancelButtonWidth;
        public int BombDefusingCancelButtonHeight;

        //following path nodes
        public int NodeWidth;
        public int NodeHeight;

        //portal dimensions
        public int PortalWidth;
        public int PortalHeight;

        #region avatar configuration
        public int AvatarWidth;
        public int AvatarHeight;
        public int AvatarWalkSpeed;
        public int AvatarHealth;
        #endregion

        #region inventory
        public int InventorySlotWidth;
        public int InventorySlotHeight;
        public int InventorySlotNameFrameHeight;
        public int InventorySlotCountFrameHeight;
        public int SecretWordInventorySlotHeight;
        public int SecretWordInventoryFontSize;
        #endregion

        #region bomb scanner
        public double BombScannerTimeElapsing;
        public double TimeToUncoverNextNode;
        public double TimeOffsetToPhase2;
        public double BombUncoverAnimationTime;
        public int UncoverEnergyCost;//how much energy will be taken on node scan
        public int EnergyBarHeight;
        public int EnergyBarWidth;
        public double RedPointerFlashTimeON;
        public double RedPointerFlashTimeOFF;

        //difficulty
        public int ScannerDifficulty; //number of nodes to show in choosing ndoes mode
        public int AutoScannerDifficulty;//number of nodes to show in choosing ndoes mode for auto scanner

        //letter
        public double LetterUncoverAnimationTime;
        public string LetterFontFace;
        
      

        public int DefaultEnergyValue;
        
        //node colors
        public float NodeVeryColdValue;
        public float NodeColdValue;
        public float NodeWarmValue;
        public float NodeHotValue;
        public float NodeVeryHotValue;

        #endregion

        #region auto scanner battery
        public int AutoScannerBatteryRefillTime;
        public int RefillValue;
        public int BatteryUsageStep; //how many move points avatar has to reach for battery to go down
        public int TakeAwayValue; //how much battery is taken
        public int BatteryBarWidth;

        #endregion

        #region bomb map
        public int MarkerWidth;
        public int MarkerHeight;
        public int ScannerMapContextMenuWidth;
        public int ScannerMapContextMenuHeight;
        public int scannerMapContextMenuButtonWidth;
        public int ScannerMapContextMenuButtonHeight;
        public int DefaultRedMarkerCount;
        public int DefautlOrangeMarkerCount;
        public int DefautlGreenMarkerCount;

        #endregion

        #endregion


        #region methods

        /// <summary>
        /// default constructor
        /// </summary>
        public WorldConfig()
        {
            try
            {
                GameTitle = "Operation Sneak Peek";
                Maps = new List<Levels.MapInfo>();
                NpcPlacement = new List<Levels.npcPlacement>();

                BreathTakeawayTime = 500;
                BreathTakeawayValue = 5;

                //inventory slots
                this.InventorySlotHeight = 60;
                this.InventorySlotWidth = 95;
                this.InventorySlotCountFrameHeight = 45;
                this.InventorySlotNameFrameHeight = 45;

                


                //bomb scanner time values
                this.BombScannerTimeElapsing = 500;
                this.TimeToUncoverNextNode = 1000;
                this.TimeOffsetToPhase2 = 150;
                this.BombUncoverAnimationTime = 250;
                this.UncoverEnergyCost = 10;
                this.EnergyBarHeight = 25;
                this.RedPointerFlashTimeON = 1500;
                this.RedPointerFlashTimeOFF = 500;

                this.AvatarHeight = 60;
                this.AvatarWidth = 30;
                this.AvatarWalkSpeed = 2;

                this.MapSelectorFrameWidth = 150;
                this.MapSelectorFrameHeight = 150;
                this.MapSelectorTitleFrameHeight = 35;
                this.MapSelectorStatisticsFrameHeight = 50;

             

                //move checkpoints
                this.CheckpointHeight = 5;
                this.CheckpointWidth = 5;

                //following path nodes
                this.NodeWidth = 30;
                this.NodeHeight = 60;

                //bomb map scanner
                this.MarkerWidth = 15;
                this.MarkerHeight = 15;
          
                this.DefaultRedMarkerCount = 35;
                this.DefautlGreenMarkerCount = 35;
                this.DefautlOrangeMarkerCount = 35;

                this.NodeVeryColdValue = 1900; //1950, 2600
                this.NodeColdValue = 1650; //1650,1900
                this.NodeWarmValue = 1300; //1350,1600
                this.NodeHotValue = 1100; //1050,1350
                this.NodeVeryHotValue = 850; //default: 750

                this.ScannerDifficulty = 4;
                this.AutoScannerDifficulty = 4;

                //auto scanner battery
                AutoScannerBatteryRefillTime = 3000;
                RefillValue = 10;
                BatteryUsageStep = 3; //how many move points avatar has to reach for battery to go down
                TakeAwayValue = 10; //how much battery is taken
                BatteryBarWidth = 10;


                this.BombDefusingCancelButtonWidth = 100;
                this.BombDefusingCancelButtonHeight =70;

                this.AvatarHealth = 100;

                this.DefaultEnergyValue = 100;
               

                this.PointsNeededFor1Star = 1000;
                this.PointsNeededFor2Stars = 2000;
                this.PointsNeededFor3Stars = 3000;

                //letter
                this.LetterFontFace = "AwardPointsFont";
                this.LetterUncoverAnimationTime = 250;


                //BELOW CODE IS NOW CALLED IN THIS.INITPROPERTIES() IN XML.PARSER.LOADCONFIG
                ////set portal dimensions
                //this.PortalWidth = this.AvatarWidth*3;
                //this.PortalHeight = this.AvatarHeight*2;
                //ScannerManager.Energy = this.DefaultEnergyValue;
                //ScannerManager.EnergyEstimate = ScannerManager.Energy;
                //ScannerManager.BatteryLevel = 100;
                //this.scannerMapContextMenuButtonWidth = this.scannerMapContextMenuButtonWidth * NodeWidth;
                //this.ScannerMapContextMenuButtonHeight = this.ScannerMapContextMenuButtonHeight * NodeHeight;
                //this.ScannerMapContextMenuWidth = this.ScannerMapContextMenuWidth * NodeWidth;
                //this.ScannerMapContextMenuHeight = this.ScannerMapContextMenuWidth * NodeHeight;

            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }


        /// <summary>
        /// init config properties
        /// that need to be inited
        /// </summary>
        public void InitProperties()
        {
            try
            {
                //set portal dimensions
                this.PortalWidth = this.AvatarWidth * 3;
                this.PortalHeight = this.AvatarHeight * 2;
                ScannerManager.Energy = this.DefaultEnergyValue;
                ScannerManager.EnergyEstimate = ScannerManager.Energy;
                ScannerManager.BatteryLevel = 100;
                this.scannerMapContextMenuButtonWidth = this.scannerMapContextMenuButtonWidth * NodeWidth;
                this.ScannerMapContextMenuButtonHeight = this.ScannerMapContextMenuButtonHeight * NodeHeight;
                this.ScannerMapContextMenuWidth = this.ScannerMapContextMenuWidth * NodeWidth;
                this.ScannerMapContextMenuHeight = this.ScannerMapContextMenuHeight * NodeHeight;
            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }


        #endregion

    }
}
